// 通过类型传递，达到灵活的控制
const func = <T, U>(param1: T, param2: U): [T, U] => {
    return [param1, param2];
}

// 类型别名
type GetArray = <T>(args: T, count: number) => T[]

const getArray: GetArray = (args: any, timer: number) => {
    return new Array(timer).fill(args);
}


interface IGetArray<T> {
    (args: T, timer: number): T[]
}
const getList: IGetArray<number> = (args: any, timer: number) => {
    return new Array(timer).fill(args);
}

interface IValueWithLength {
    length: number
}


// 泛型约束
const getArray2 = <T extends IValueWithLength>(args: T, timer: number): T[] => {
    return new Array(timer).fill(args);
}
getArray2('2', 3);


const getProps = <T, K extends keyof T>(props: T, propsName: K): any => {
    return props[propsName];
}

const target = {
    a: 1,
    b: 2,
}
getProps(target, 'a')
export {};